package person.bing.fbcloud.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import person.bing.fbcloud.api.entity.SysRouteDetail;
import person.bing.fbcloud.common.core.util.R;
import person.bing.fbcloud.common.log.annotation.SysLog;
import person.bing.fbcloud.service.SysRouteDetailService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mengfb
 * @since 2020-03-16
 */
@RestController
@RequestMapping("/sysRouteDetail")
public class SysRouteDetailController {
    @Autowired
    private SysRouteDetailService sysRouteDetailService;

    /**
     * 分页
     * @param page
     * @param sysRouteDetail
     * @return
     */
    @SysLog("系统路由分页")
    @GetMapping("/page")
    public R page(Page page, SysRouteDetail sysRouteDetail){
        return new R(sysRouteDetailService.page(page));
    }

    /**
     * 根据id获取详情
     * @return
     */
    @GetMapping("/{id}")
    public R getById(@PathVariable String id){
        return new R(sysRouteDetailService.getById(id));
    }

    /**
     * 新增
     * @param sysRouteDetail
     * @return
     */
    @PostMapping
    public R add(@RequestBody SysRouteDetail sysRouteDetail){
        return new R(sysRouteDetailService.save(sysRouteDetail));
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R delete(@PathVariable String id){
        return new R(sysRouteDetailService.removeById(id));
    }

    /**
     * 根据id修改
     * @param sysRouteDetail
     * @return
     */
    @PutMapping
    public R update(@RequestBody SysRouteDetail sysRouteDetail){
        return new R(sysRouteDetailService.updateById(sysRouteDetail));
    }
}
